

//
//  DetailTableViewController.swift
//  Contact
//
//  Created by YYY on 2017/7/20.
//  Copyright © 2017年 成品家（北京）网路科技有限公司. All rights reserved.
//

import UIKit

//_ 忽略一切不关心的内容
class DetailTableViewController: UITableViewController
{
    //闭包回调
    var completion: (() -> ())?
    
    
    //姓名
    @IBOutlet weak var nameTextField: UITextField!
    
    //手机号
    @IBOutlet weak var phoneTextField: UITextField!
    
    //职务
    @IBOutlet weak var titleTextField: UITextField!
    
    var person: Person?
    
    //保存
    @IBAction func saveAction(_ sender: Any)
    {
        if person==nil
        {
            person = Person()
        }
        person?.name = nameTextField.text
        person?.phone = phoneTextField.text
        person?.title = titleTextField.text
        completion?()
        navigationController?.popViewController(animated: true)
    }
    override func viewDidLoad() {
        super.viewDidLoad()

        if person != nil
        {
            nameTextField.text = person?.name
            phoneTextField.text = person?.phone
            titleTextField.text = person?.title
            
        }
        // Uncomment the following line to preserve selection between presentations
        // self.clearsSelectionOnViewWillAppear = false

        // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
        // self.navigationItem.rightBarButtonItem = self.editButtonItem()
    }

}
